﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace FileBrowser.Model
{
    public class CustomDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate FolderTemplate { get; set; }
        public DataTemplate FileTemplate { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null && item is IData)
            {
                IData taskitem = item as IData;

                if (taskitem.getType() == IData.Type.File)
                {
                    return FileTemplate;
                }
                else
                {
                    var selectorItem = container as SelectorItem;
                    
                    //selectorItem.IsEnabled = false;
                    return FolderTemplate;
                }
            }

            return null;
        }

      
    }
}
